<template>
  <div class="course-outline">
    <div class="markdown-content" v-if="markdownHTML">
      <div v-html="markdownHTML"></div>
    </div>
    <div class="no-data" v-else>
      <img src="@/assets/img/no-data.png" alt="" />
      <div class="no-data-text">暂无内容</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      courseId: JSON.parse(localStorage.getItem("courseId")),
      markdownContent: "",
      markdownHTML: "",
    };
  },
  mounted() {
    this.getMarkdownContent();
  },
  methods: {
    // 获取markdown内容
    getMarkdownContent() {
      this.$axios
        .get(`/tes/course/${this.courseId}/resource?resourceType=15`)
        .then((res) => {
          this.markdownHTML =
            res.data.courseOutline.displayVersion[0]?.htmlContent;
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.course-outline {
  background-color: #f3f5fa;
  padding: 0px 30px 40px;
  box-sizing: border-box;
  min-height: 650px;
  .markdown-content {
    margin: 0 auto;
    width: 1254px;
    height: 100%;
    padding: 20px;
    background-color: #fff;
  }
  .no-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 230px 0;
    height: 100%;
    gap: 10px;
    .no-data-text {
      font-size: 16px;
      color: #999;
    }
  }
}
</style>